﻿using System;
using System.AddIn.Pipeline;
using RootfusAddinView;
using RootfusAddinContracts;

namespace RootfusAddinAddinSideAdapters
{
    public class PinDefinitionContractToViewAdaptor : PinDefinition
    {
        IPinDefinitionContract _contract;
        ContractHandle _handle;

        public PinDefinitionContractToViewAdaptor(IPinDefinitionContract contract)
        {
            _contract = contract;
            _handle = new ContractHandle(contract);
        }

        public IPinDefinitionContract GetSourceContract()
        {
            return _contract;
        }

        #region PinDefinition Members

        public override string Name
        {
            get { return _contract.Name; }
        }

        #endregion

        #region PinDefinition Members


        public override RootfusAddinView.PinConnectionType ConnectionType
        {
            get {
                switch (_contract.ConnectionType)
                {
                    case RootfusAddinContracts.PinConnectionType.PinInfinite:
                        return RootfusAddinView.PinConnectionType.PinInfinite;
                    case RootfusAddinContracts.PinConnectionType.PinSingle:
                        return RootfusAddinView.PinConnectionType.PinSingle;
                    default:
                        throw new Exception("Not implemented!");
                }
            }
        }

        #endregion
    }
}
